#ifndef PERIPHERALMODEL_H
#define PERIPHERALMODEL_H

#include <QAbstractItemModel>


class Widget;

class PeripheralModel : public QAbstractItemModel
{
    Q_OBJECT
public:
    explicit PeripheralModel(QObject *parent = nullptr);

    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;

    QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
    QModelIndex parent(const QModelIndex &index) const override;

    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;

    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;

    void beginInsertObject(Widget *obj);
    void endInsertObject();

    void beginRemoveObject(Widget *obj);
    void endRemoveObject();

    Widget *object(const QModelIndex &index) const;
    void setCurrentObject(Widget *obj);

    //Qt::ItemFlags flags(const QModelIndex &index) const override;
    QMap<QString,QStringList> GetJsonData(QMap<QString,QStringList*>* a);//获取外设json数据
private:
    QModelIndex objIndex(Widget *obj, int col) const;

    Widget *m_current;



};

#endif // PeripheralModel_H
